package com.hb0730.boot.admin.modules.sci.service;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hb0730.boot.admin.base.R;
import com.hb0730.boot.admin.core.service.BaseServiceImpl;
import com.hb0730.boot.admin.data.domain.BasePage;
import com.hb0730.boot.admin.modules.sci.model.entity.SciPaperJournal;
import com.hb0730.boot.admin.modules.sci.mapper.SciPaperJournalMapper;
import com.hb0730.boot.admin.modules.sci.model.query.SciPaperJournalQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author 31673
* @description 针对表【sci_paper_journal(科研期刊论文表)】的数据库操作Service实现
* @createDate 2024-10-24 12:39:19
*/
@Service
public class SciPaperJournalService extends BaseServiceImpl<SciPaperJournalMapper, SciPaperJournal> {

    public BasePage<SciPaperJournal> queryPage(SciPaperJournalQuery query) {
        Page<SciPaperJournal> page = new Page<>(query.getCurrent(), query.getSize());
        List<SciPaperJournal> vos = this.baseMapper.queryPage(page, query);
        return new BasePage<>(page.getCurrent(), page.getSize(), page.getTotal(), vos);
    }
    public R<SciPaperJournal> updateById(String id, SciPaperJournal sciPaperJournal) {
        System.out.println("apo");
        SciPaperJournal sciPaperJournal0 = getById(id);
        if (null == sciPaperJournal0) {
            return R.NG("用户不存在");
        }
        System.out.println("ap1");
        updateById(sciPaperJournal);
        return R.OK(sciPaperJournal);
    }
    @Transactional(rollbackFor = Exception.class)
    public R<SciPaperJournal> saveJournal(SciPaperJournal sciPaperJournal) {
        super.save(sciPaperJournal);
        return R.OK(sciPaperJournal);
    }

    public R<String> deleteByIds(List<String> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return R.NG("参数不能为空");
        }
        removeByIds(ids);
        return R.OK();
    }
}




